﻿<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	
	<title>iStock-Web股票平台</title>
	
	<link rel="stylesheet" href="/site_media/css/stock.css" type="text/css" />
	
	<script type="text/javascript" src="/site_media/js/jquery-1.5.min.js"></script>
	<script type="text/javascript" src="/site_media/js/jquery.json-2.2.min.js"></script>
	
	<!--[if  lte IE 6 ]>
        <style type="text/css">
        #search{
            margin:12px 0 0 0px;
        }
        

        </style>
    <![endif]-->
	
	<script type="text/javascript">
		
		
		$(document).ready(function(){
			
			$("#btnaddstock").click(function(){
					var stockid = $("#sstock").val();
					if(stockid != null){
						var newrow = "<tr align='center' id='"+stockid+"'>";
						
						newrow += "<td>"+"<input type='checkbox' id='"+stockid+"' />"+"</td>";
						newrow += "<td>"+stockid+"</td>";
						newrow += "<td>"+stockid+"</td>";
						newrow += "<td>"+stockid+"</td>";
						newrow += "<td>"+stockid+"</td>";
						newrow += "<td>"+stockid+"</td>";
						newrow += "<td>"+stockid+"</td>";
						newrow += "<td>"+stockid+"</td>";
						
						newrow += "</tr>";
						//alert(newrow);
						$("#stockpool").append(newrow);
					}
			});
			
			$("#btnscript").click(function(){
					//alert($("#stockpool").children().eq(0).html());
					var stockarr = new Array();
					$("#stockpool"+">tr").each(function(){
					    //alert($(this).attr("id"));
						var sid = $(this).attr("id");
						stockarr.push(sid);
				    });
					
					$("#resultpool").html("");
					var $scripttext = $("#sscript");
					
					for(var i = 0; i < stockarr.length; i++){
						var scriptform = "";
						scriptform += "<form method='post' action='/test4/'>";
		                scriptform += "<input name='script' type='hidden' value='"+ encodeURIComponent($scripttext.val().toString())+"'/>";
		                scriptform += "<input name='stockid' type='hidden' value='"+stockarr[i]+"'/>";
		                scriptform += "<input type='submit' value='查看结果'/>";
		                scriptform += "</form>";
		                
		                $("#resultpool").append("<tr><td>"+stockarr[i]+"<td><td>"+scriptform+"</td></tr>");
					}
					
					/*$(".viewres").click(function(){
						alert("hello");
						var $scripttext = $("#sscript");
						var stockid = $(this).attr("id");
						
						$.ajax({
							url: "/test4/",
							type: "POST",
							data: "script="+encodeURIComponent($scripttext.val().toString())+"&"+"stockid="+ stockid,
								
							success: function( data ) {
								alert(data);
							},
							error: function(data){
								alert("post data error");
							}
						});
						
					});*/
					alert($("#resultpool").html());
					
					return;
					
			});
			
			
		});
		
	</script>

</head>
<body>
  <div id="content">
	  	{% if uid %}
			<div id="top_info"><a href="/istock/login" >{{uid}}</a> | <a href="/istock/logout/">退出</a></div>	
		{% else %}
			<div id="top_info"><a href="/istock/login" >登录</a></div>	
		{% endif %}
		
		
  		<div id="header">
			<div class="logo">
				<img src="/site_media/images/iStock.png"  alt=""/>
			</div>
			<div id="search"> 
				<form method="post" action="#"> 
					<p><input type="text" name="searchid" class="search" id="stext" /> <input type="submit" value="iStock搜索" class="button" /></p> 
				</form> 
			</div> 
		</div>

		<div id="main">
		    
		    
		    <div id="left">
		            <ul>
		                <li><a href="#">首页</a></li>
		                <li><a href="#">我的首页</a></li>
		                <li><a href="#">我的股票</a></li>
		                <li><a href="#">我的公式</a></li>
		                <li><a href="#">公式计算</a></li>
		                <li><a href="#">公式选股</a></li>
		                <li><a href="#">指标比较</a></li>      
		            </ul>
		    </div>
		    
		    <div id="center" >
			    <div class="myuiheader"></div>
			    <div>
					<table width="100%">
						<thead>
						<tr>
							<th>选择</th>
							<th>股票代码</th>
							<th>股票名称</th>
							<th>开盘</th>
							<th>最低</th>
							<th>最高</th>
							<th>收盘</th>
							<th>成交量</th>
						</tr>
						</thead>
						<tbody id="stockpool" >
						</tbody>
					</table>
				</div>
			    <div class="myuiaddbar">
			        <table>
			            <tr>
			              <td><span style="font-size:14px; margin-right:5px;">股票代码</span></td><td><input type=text  id="sstock"/></td><td><input type="button" value="添加股票" class="button" id="btnaddstock"/></td><td><input type="button" value="从我关注的股票添加"/></td><td><input type="button" value="删除" /></td>
			            </tr>
			        </table>
			    </div>
			    
			    <div class="myuiscript" id="doc">
			        
			        <div class="myuiinput">
			        	<textarea  style="margin-left:0;" rows="22" cols="35" name="sscript" id="sscript"></textarea>
			            <input type="button" value="提交" id="btnscript"/>	
			        </div>
			         <div class="myuiresult">
			       		<table id="resultpool">
						</table>
			        </div>
			    </div>
			    
            </div>
            
		</div>
		<div id="footer">
			<p>&nbsp;&nbsp;<a href="">关于我们</a> &nbsp;&nbsp; | &nbsp;&nbsp;<a href="">免责声明 </a>&nbsp;&nbsp;| &nbsp;&nbsp;<a href="">联系我们</a> &nbsp;&nbsp;| &nbsp;&nbsp;<a href="">帮助中心</a>&nbsp;&nbsp;</p>
		</div>
		
  </div>
  
  
</body>
</html>
